<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  >
      <el-form-item label="姓名" prop="username">
        <el-input
          v-model="queryParams.username"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始时间" prop="leaveStartTime">
        <el-date-picker clearable
          v-model="queryParams.leaveStartTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="leaveEndTime">
        <el-date-picker clearable
          v-model="queryParams.leaveEndTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择结束时间">
        </el-date-picker>
      </el-form-item>
      <br/>
      <div style="text-align: right;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </div>
    </el-form>
      <br/>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['module:cjl:vacation:add']"
        >新增</el-button>
      </el-col>
      <!--<el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['module:cjl:vacation:edit']"
        >修改</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['module:cjl:vacation:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['module:cjl:vacation:export']"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="vacationList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" width="55" :index="indexMethod" align="center" />
      <el-table-column label="姓名" align="center" prop="username" />
      <el-table-column label="部门" align="center" prop="dept.deptName" />
      <el-table-column label="负责人审阅结果" align="center" prop="departmentHeadResult" >
      <template slot-scope="scope">
        <span v-if="scope.row.departmentHeadResult==1">已阅知</span>
      </template>
      </el-table-column>
      <el-table-column label="局长审阅结果" align="center" prop="directorGeneralResult" >
      <template slot-scope="scope">
        <span v-if="scope.row.directorGeneralResult==1">已阅知</span>
      </template>
      </el-table-column>
      <el-table-column label="政委审阅结果" align="center" prop="politicalCommissarResult" >
      <template slot-scope="scope">
        <span v-if="scope.row.politicalCommissarResult==1">已阅知</span>
      </template>
      </el-table-column>
      <el-table-column label="销假状态" align="center" prop=" leaveSituation" >
        <template slot-scope="scope">
          <span v-if="scope.row.leaveSituation==0">未销假</span>
          <span v-if="scope.row.leaveSituation==1">已销假</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['module:cjl:vacation:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['module:cjl:vacation:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDetail(scope.row,scope.index)"
            v-hasPermi="['module:cjl:vacation:detail']"
          >详细</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleBack(scope.row,scope.index)"
            v-hasPermi="['module:cjl:vacation:back']"
          >销假</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['module:cjl:vacation:view']"
          >单位审阅</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleChief(scope.row,scope.index)"
            v-hasPermi="['module:cjl:vacation:chief']"
          >局长审阅</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleGaott(scope.row,scope.index)"
            v-hasPermi="['module:cjl:vacation:gaott']"
          >政委审阅</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!-- 添加或修改休假记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择开始时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择结束时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1" placeholder="请输入内容" maxlength="500"/>
            </el-form-item>
            <el-row>
             <el-col :span="12">
             <el-form-item label="休假地点" prop="leaveAddress" >
               <el-cascader
                 v-model="selectedOptions"
                 :options="options"
                 filterable
                 clearable
                 style="width: 380px"
                 placeholder="请选择休假地点"
                 @change="handleChange"
               />
             </el-form-item>
             </el-col>
             </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查看审核详细休假记录对话框 -->
    <el-dialog :title="detail.title" :visible.sync="detail.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1"  readonly="true"/>
            </el-form-item>
            <el-form-item label="休假地点" prop="leaveAddress" >
               <el-cascader
                 v-model="selectedOptions"
                 :options="options"
                 filterable
                 clearable
                 style="width: 460px"
                 disabled="true"
                 @change="handleChange"
               />
             </el-form-item>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">部门审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="departmentHeadResult">
                  <el-radio-group v-model="form.departmentHeadResult" disabled="true">
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门负责人阅知时间" prop="departmentHeadTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.departmentHeadTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">局长审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="directorGeneralResult">
                  <el-radio-group v-model="form.directorGeneralResult" disabled="true" >
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="局长审阅时间" prop="directorGeneralTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.directorGeneralTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">政委审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="politicalCommissarResult">
                  <el-radio-group v-model="form.politicalCommissarResult" disabled="true">
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="政委审阅时间" prop="politicalCommissarTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.politicalCommissarTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="detailCancel">返 回</el-button>
      </div>
    </el-dialog>
    <!-- 销假审核详细休假记录对话框 -->
    <el-dialog :title="back.title" :visible.sync="back.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1"  readonly="true"/>
            </el-form-item>
            <el-form-item label="休假地点" prop="leaveAddress" >
              <el-cascader
                v-model="selectedOptions"
                :options="options"
                filterable
                clearable
                style="width: 460px"
                disabled="true"
                @change="handleChange"
              />
            </el-form-item>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">部门审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="departmentHeadResult">
                  <el-radio-group v-model="form.departmentHeadResult" disabled="true">
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门负责人审阅时间" prop="departmentHeadTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.departmentHeadTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">局长审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="directorGeneralResult">
                  <el-radio-group v-model="form.directorGeneralResult" disabled="true">
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="局长审阅时间" prop="directorGeneralTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.directorGeneralTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">政委审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="politicalCommissarResult">
                  <el-radio-group v-model="form.politicalCommissarResult" disabled="true">
                    <el-radio label="1">已审阅</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="政委审阅时间" prop="politicalCommissarTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.politicalCommissarTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">销假信息</p>
            </el-divider>
          </el-header>
          <el-row>
            <el-form-item  prop="leaveSituation">
              <el-radio v-model="radio" label="1">确认销假</el-radio>
              <!--<el-radio-group v-model="form.leaveSituation" >
                <el-radio label="2">确认销假</el-radio>
              </el-radio-group>-->
            </el-form-item>
          </el-row>
          <el-main>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="backForm">确 定</el-button>
        <el-button @click="backCancel">返 回</el-button>
      </div>
    </el-dialog>
    <!-- 部门审核休假记录对话框 -->
    <el-dialog :title="view.title" :visible.sync="view.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="username">
                  <el-input v-model="form.username" placeholder="请输入姓名" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptId">
                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" disabled="true" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="休假地点" prop="leaveAddress" >
              <el-cascader
                v-model="selectedOptions"
                :options="options"
                filterable
                clearable
                style="width: 1070px"
                disabled="true"
                @change="handleChange"
              />
            </el-form-item>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1"  readonly="true"/>
            </el-form-item>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择开始时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择结束时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">部门审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="departmentHeadResult">
                    <el-radio v-model="radio" label="1">已审阅</el-radio>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门负责人审阅时间" prop="departmentHeadTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.departmentHeadTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true"
                    placeholder="请选择部门负责人审阅时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="viewForm">确 定</el-button>
        <el-button @click="viewCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 局长阅知休假记录对话框 -->
    <el-dialog :title="chief.title" :visible.sync="chief.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="username">
                  <el-input v-model="form.username"  readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptId">
                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" disabled="true" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="休假地点" prop="leaveAddress" >
              <el-cascader
                v-model="selectedOptions"
                :options="options"
                filterable
                clearable
                style="width: 1070px"
                disabled="true"
                @change="handleChange"
              />
            </el-form-item>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1"  readonly="true"/>
              <!-- <editor v-model="form.causes" :min-height="192" readonly="true" />-->
            </el-form-item>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择开始时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择结束时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">局长审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="directorGeneralResult">
                  <el-radio v-model="radio" label="1">已审阅</el-radio>
                  <!--<el-radio-group v-model="form.directorGeneralResult" >
                  <el-radio label="1">已阅知</el-radio>
                </el-radio-group>-->
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="局长审阅时间" prop="directorGeneralTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.directorGeneralTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true"
                    placeholder="请选择局长审阅时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="chiefForm">确 定</el-button>
        <el-button @click="chiefCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 政委审核休假记录对话框 -->
    <el-dialog :title="gaott.title" :visible.sync="gaott.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">休假申请基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="username">
                  <el-input v-model="form.username" placeholder="请输入姓名" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptId">
                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" disabled="true" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="休假地点" prop="leaveAddress" >
              <el-cascader
                v-model="selectedOptions"
                :options="options"
                filterable
                clearable
                style="width: 1070px"
                disabled="true"
                @change="handleChange"
              />
            </el-form-item>
            <el-form-item label="备注" prop="causes">
              <el-input v-model="form.causes" type="textarea" :rows="1"  readonly="true"/>
              <!-- <editor v-model="form.causes" :min-height="192" readonly="true" />-->
            </el-form-item>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="leaveStartTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveStartTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择开始时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="leaveEndTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.leaveEndTime"
                    type="date"
                    readonly="true"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择结束时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">政委审阅</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item  prop="politicalCommissarResult">
                  <el-radio v-model="radio" label="1">已审阅</el-radio>
                  <!--<el-radio-group v-model="form.politicalCommissarResult" >
                    <el-radio label="1">已阅知</el-radio>
                  </el-radio-group>-->
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="政委审阅时间" prop="politicalCommissarTime">
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.politicalCommissarTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true"
                    placeholder="请选择政委审阅时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="gaottForm">确 定</el-button>
        <el-button @click="gaottCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listVacation, getVacation, delVacation, addVacation, updateVacation,viewVacation,chiefYhVacation,gaottYhVacation,backYhVacation} from "@/api/module/cjl/vacation";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import watermark from "watermark-dom";
// 导入省市区数据组件
import { provinceAndCityData,CodeToText, TextToCode } from 'element-china-area-data'
export default {
  name: "Vacation",
  components: { Treeselect },
  data() {
    return {
      radio: '1',
      //城市选项
      options: provinceAndCityData,
      selectedOptions: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 休假记录表格数据
      vacationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        department: null,
        username: null,
        idNumber: null,
        deptid: null,
        causes: null,
        leaveStartTime: null,
        leaveEndTime: null,
        leaveSituation: null,
        leaveAddress: null,
        userId: null,
        deptId: null,
        departmentHeadName: null,
        departmentHeadIdnum: null,
        departmentHeadResult: null,
        departmentHeadTime: null,
        departmentHeadSuggest: null,
        departmentHeadIsacting: null,
        departmentHeadCharacter: null,
        directorGeneralName: null,
        directorGeneralIdnum: null,
        directorGeneralResult: null,
        directorGeneralTime: null,
        directorGeneralSuggest: null,
        directorGeneralIsacting: null,
        directorGeneralCharacter: null,
        politicalCommissarName: null,
        politicalCommissarIdnum: null,
        politicalCommissarResult: null,
        politicalCommissarTime: null,
        politicalCommissarSuggest: null,
        politicalCommissarIsacting: null,
        politicalCommissarCharacter: null,
        leaveTotalState: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 查看审核查询参数
      detail:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 销假审核查询参数
      back:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 部门审核查询参数
      view:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 局长审核查询参数
      chief:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 政委审核查询参数
      gaott:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 表单参数
      form: {
        departmentHeadTime:this.getNowTime(),
        directorGeneralTime:this.getNowTime(),
        politicalCommissarTime:this.getNowTime()},
      // 表单校验
      rules: {
        leaveStartTime: [
          { required: true, message: "开始时间不能为空", trigger: "blur" },
        ],
        leaveEndTime: [
          { required: true, message: "结束时间不能为空", trigger: "blur" },
        ],
        leaveAddress: [
          { required: true, message: "休假地点不能为空", trigger: "blur" },
        ],
      }
    };
  },
  mounted() {
    watermark.load({ watermark_txt: "  "   });
  },
  created() {
    this.getList();
    this.getTreeselect();
    this.getNowTime();
  },
  methods: {
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    handleChange (value) {
     console.log(value)
     this.getCodeToText(null,value)
   },
   getCodeToText (codeStr, codeArray) {
     if (null === codeStr && null === codeArray) {
       return null;
     } else if (null === codeArray) {
       codeArray = codeStr.split(",");
     }
     let leaveAddress = "";
     switch (codeArray.length) {
       case 1:
         leaveAddress += CodeToText[codeArray[0]];
         break;
       case 2:
         leaveAddress += CodeToText[codeArray[0]] + "/" + CodeToText[codeArray[1]];
         break;
       default:
         break;
     }
     this.form.leaveAddress = leaveAddress
     return leaveAddress;
   },
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      month = month + 1;
      month = month.toString().padStart(2, "0");
      date = date.toString().padStart(2, "0");
      var defaultDate = `${year}-${month}-${date}`;
      return defaultDate;
    },
    /** 查询休假记录列表 */
    getList() {
      this.loading = true;
      listVacation(this.queryParams).then(response => {
        this.vacationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    detailCancel() {
      this.detail.open = false;
      this.reset();
    },
    // 取消按钮
    backCancel(){
      this.back.open = false;
      this.reset();
    },
    // 取消按钮
    viewCancel() {
      this.view.open = false;
      this.reset();
    },
    // 取消按钮
    chiefCancel() {
      this.chief.open = false;
      this.reset();
    },
    // 取消按钮
    gaottCancel() {
      this.gaott.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        department: null,
        username: null,
        idNumber: null,
        deptid: null,
        causes: null,
        leaveStartTime: null,
        leaveEndTime: null,
        leaveSituation: null,
        leaveAddress: null,
        userId: null,
        deptId: null,
        departmentHeadName: null,
        departmentHeadIdnum: null,
        departmentHeadResult: null,
        departmentHeadTime: null,
        departmentHeadSuggest: null,
        departmentHeadIsacting: null,
        departmentHeadCharacter: null,
        directorGeneralName: null,
        directorGeneralIdnum: null,
        directorGeneralResult: null,
        directorGeneralTime: null,
        directorGeneralSuggest: null,
        directorGeneralIsacting: null,
        directorGeneralCharacter: null,
        politicalCommissarName: null,
        politicalCommissarIdnum: null,
        politicalCommissarResult: null,
        politicalCommissarTime: null,
        politicalCommissarSuggest: null,
        politicalCommissarIsacting: null,
        politicalCommissarCharacter: null,
        leaveTotalState: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.is=selection.map(item => item.username)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.selectedOptions=[];
      this.open = true;
      this.title = "添加休假记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.open = true;
        this.title = "修改休假记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateVacation(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addVacation(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 销假按钮 */
    backForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            backYhVacation(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.back.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 部门审核按钮 */
    viewForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            viewVacation(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.view.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 局长审核按钮 */
    chiefForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            chiefYhVacation(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.chief.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 政委审核按钮 */
    gaottForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            gaottYhVacation(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.gaott.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 详细按钮操作 */
    handleDetail(row) {
     /* const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.detail.open = true;
        this.detail.title = "休假申请详细";
      });*/
      const id = row.id;
      this.$router.push({ path:"/zonghe/vacation_detail", query: {id}});
    },
    /** 销假按钮操作 */
    handleBack(row) {
      const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.back.open = true;
        this.back.title = "销假详细";
      });
    },
    /** 部门详细按钮操作 */
    handleView(row) {
      const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.form.departmentHeadTime=this.getNowTime();
        this.view.open = true;
        this.view.title = "审阅休假申请";
      });
    },
    /** 局长详细按钮操作 */
    handleChief(row) {
      const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.form.directorGeneralTime=this.getNowTime();
        this.chief.open = true;
        this.chief.title = "审阅休假申请";
      });
    },
    /** 政委详细按钮操作 */
    handleGaott(row) {
      const id = row.id || this.ids
      getVacation(id).then(response => {
        this.form = response.data;
        this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;
        this.form.politicalCommissarTime=this.getNowTime();
        this.gaott.open = true;
        this.gaott.title = "审阅休假申请";
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const i=row.username || this.is;
      this.$modal.confirm('是否确认删除姓名为"' + i + '"的数据项？').then(function() {
        return delVacation(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('module/cjl/vacation/export', {
        ...this.queryParams
      }, `vacation_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /*对话框标题样式*/
  .el-dialog__title{
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }

</style>
